<!--
Date: 2025-08-13
Copyright (c) 2025 Industrial Software Feature Database
-->
<template>
  <div class="check-result">
    <div class="check-result-total">
      <h3>本次数据检验是将导入的数据与原始装机清单的数据进行检查而得出，检测结果如下：</h3>
      <h3>共检测<span style="color: red">{{ props.checkTotal }}</span>条数据，其中零件或者紧固件不存在的<span style="color: red">{{ props.notExistsList.length }}</span>条，其中零件或者紧固件版本不一致的<span style="color: red">{{ props.versionNotSameList.length }}</span>条，零件或者紧固件数量不一致的<span style="color: red">{{ props.dataNotSameList.length }}</span>条。</h3>
    </div>
    <div class="check-result-main">
      <el-card v-if="props.notExistsList.length > 0" style="width: 100%;">
        <h4 class="title">原始清单不存在的数据</h4>
        <el-table :data="tableData1" max-height="400px">
          <el-table-column type="index" label="序号" fixed="left" width="60">
            <template #default="scope">
              {{ scope.$index + 1 + (pageNum1 - 1) * pageSize1 }}
            </template>
          </el-table-column>
          <el-table-column prop="partNumber" label="编号"></el-table-column>
          <el-table-column prop="fileType" label="类型">
            <template #default="scope">
              {{ fileTypeMap[scope.row.fileType] }}
            </template>
          </el-table-column>
          <el-table-column prop="versionNumber" label="版本号"></el-table-column>
          <el-table-column prop="componentNumber" label="所属组件"></el-table-column>
          <el-table-column prop="sectionNumber" label="所属部段"></el-table-column>
          <el-table-column prop="modelNumber" label="所属机型"></el-table-column>
        </el-table>
        <div class="pagenation">
          <el-pagination
            v-show="total1 > 0"
            layout="prev, pager, next,jumper"
            v-model:page="pageNum1"
            v-model:limit="pageSize1"
            :total="total1"
            @current-change="handleCurrentChange1"
          />
        </div>
      </el-card>
      <el-card v-if="props.versionNotSameList.length > 0" style="width: 100%; margin-top:20px;">
        <h4 class="title">零件版本不匹配的数据</h4>
        <el-table :data="tableData2" max-height="400px">
          <el-table-column type="index" label="序号" fixed="left" width="60">
            <template #default="scope">
              {{ scope.$index + 1 + (pageNum2 - 1) * pageSize2 }}
            </template>
          </el-table-column> 
          <el-table-column prop="partNumber" label="编号"></el-table-column>
          <el-table-column prop="fileType" label="类型">
            <template #default="scope">
              {{ fileTypeMap[scope.row.fileType] }}
            </template>
          </el-table-column>
          <el-table-column prop="componentNumber" label="所属组件"></el-table-column>
          <el-table-column prop="sectionNumber" label="所属部段"></el-table-column>
          <el-table-column prop="modelNumber" label="所属机型"></el-table-column>
          <el-table-column prop="versionNumber" label="导入版本号" width="160"></el-table-column>
          <el-table-column prop="originalVersion" label="对应原始装机清单的版本号" width="200"></el-table-column>
        </el-table>
        <div class="pagenation">
          <el-pagination
            v-show="total2 > 0"
            layout="prev, pager, next,jumper"
            v-model:page="pageNum2"
            v-model:limit="pageSize2"
            :total="total2"
            @current-change="handleCurrentChange2"
          />
        </div>
      </el-card>
      <el-card v-if="props.dataNotSameList.length > 0" style="width: 100%; margin-top:20px;">
        <h4 class="title">零件数量不一致的数据</h4>
        <el-table :data="tableData3" max-height="400px">
          <el-table-column type="index" label="序号" fixed="left" width="60">
            <template #default="scope"> {{ scope.$index + 1 + (pageNum3 - 1) * pageSize3 }} </template>
          </el-table-column>
          <el-table-column prop="partNumber" label="编号"></el-table-column>
          <el-table-column prop="fileType" label="类型">
            <template #default="scope">
              {{ fileTypeMap[scope.row.fileType] }}
            </template>
          </el-table-column>
          <el-table-column prop="versionNumber" label="版本号"></el-table-column>
          <el-table-column prop="componentNumber" label="所属组件"></el-table-column>
          <el-table-column prop="sectionNumber" label="所属部段"></el-table-column>
          <el-table-column prop="modelNumber" label="所属机型"></el-table-column>
          <el-table-column prop="importCount" label="导入数量"></el-table-column>
          <el-table-column prop="originalImportCount" label="对应原始装机清单的数量" width="200"></el-table-column>
        </el-table>
        <div class="pagenation">
          <el-pagination
            v-show="total3 > 0"
            layout="prev, pager, next,jumper"
            v-model:page="pageNum3"
            v-model:limit="pageSize3"
            :total="total3"
            @current-change="handleCurrentChange3"
          />
        </div>
      </el-card>
    </div>
  </div>
</template>
<script name="CheckResult" setup>
const props = defineProps(['checkTotal', 'versionNotSameList', 'dataNotSameList', 'notExistsList']);
const pageSize1 = ref(10);
const pageNum1 = ref(1);
const total1 = ref(0);
const pageSize2 = ref(10);
const pageNum2 = ref(1);
const total2 = ref(0);
const pageSize3 = ref(10);
const pageNum3 = ref(1);
const total3 = ref(0);
const tableData1 = ref([]);
const tableData2 = ref([]);
const tableData3 = ref([]);
const fileTypeMap = {
  'part': '零件',
  'fastener': '紧固件'
}
const handleCurrentChange1 = (currentPage) => {
  pageNum1.value = currentPage;
  queryByCondition(1);
};    
const handleCurrentChange2 = (currentPage) => {          
  pageNum2.value = currentPage;
  queryByCondition(2);
};    
const handleCurrentChange3 = (currentPage) => {          
  pageNum3.value = currentPage;
  queryByCondition(3);
};    
const queryByCondition = (type) => {
  if (type === 1) {
    tableData1.value = props.notExistsList.slice((pageNum1.value - 1) * pageSize1.value, pageNum1.value * pageSize1.value);
    total1.value = props.notExistsList.length;
  } else if (type === 2) {
    tableData2.value = props.versionNotSameList.slice((pageNum2.value - 1) * pageSize2.value, pageNum2.value * pageSize2.value);
    total2.value = props.versionNotSameList.length;
  } else if (type === 3) {
    tableData3.value = props.dataNotSameList.slice((pageNum3.value - 1) * pageSize3.value, pageNum3.value * pageSize3.value);
    total3.value = props.dataNotSameList.length;
  }
}
onMounted(() => {
  queryByCondition(1);
  queryByCondition(2);
  queryByCondition(3);
});
</script>
<style lang="scss" scoped>
.pagenation {
  margin-top: 10px;
  display: flex;
  justify-content: end;
}
</style>